#version 330

precision highp float;

uniform mat4 modelViewMatrix;
uniform mat4 projectionMatrix;

uniform vec3 sunPosition;
uniform vec3 rotX;
uniform vec3 rotY;
uniform vec3 rotZ;
uniform vec3 modelPosition;

in vec3 vPosition;
in vec3 vNormal;
in vec2 vTexCoord;
in vec3 vTangent;

out VertexData
{
	vec3 worldPos;
	vec3 normal;
	vec3 tangent;
	vec3 bitangent;	
	vec2 texCoord;
	vec4 color;
} outData;

void main()
{		
	vec3 rotatedPosition = vPosition.x * rotX + vPosition.y * rotY + vPosition.z * rotZ;	
	vec3 translatedPosition = rotatedPosition + modelPosition;
		                    
	outData.normal = vNormal;
	outData.tangent = vTangent;
	outData.normal = vNormal.x * rotX + vNormal.y * rotY + vNormal.z * rotZ;	
	outData.tangent = vTangent.x * rotX + vTangent.y * rotY + vTangent.z * rotZ; 
	outData.bitangent = cross(outData.normal, outData.tangent);
	outData.worldPos = translatedPosition;
	outData.texCoord = vTexCoord.st;
	outData.color = vec4(0, 0, 0, 1);
			
	gl_Position = projectionMatrix * modelViewMatrix * vec4(translatedPosition, 1);
}